﻿using FadeLang.Ast;
using FadeLang.Runtime;

namespace FadeLang.CstVisitor
{
    internal class BlockVisitor : FadeLangBaseVisitor<Block>
    {
        private readonly Context context;

        public BlockVisitor(Context context) {
            this.context = context;
        }

        public override Block VisitBlock(FadeLangParser.BlockContext context) {
            var block = new Block();
            foreach (var statContext in context.stat()) {
                block.Statements.Add(statContext.Accept(new StatementVisitor(this.context)));
            }
            return block;
        }
    }
}